/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DataSourceBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.common.soap.SoapFaultException;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.DataSource;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.datasource.DataSourceManager;
/*    */ import com.zimbra.cs.datasource.ImportStatus;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.type.DataSourceType;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetImportStatus
/*    */   extends MailDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException, SoapFaultException
/*    */   {
/* 40 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 41 */     Account account = getRequestedAccount(zsc);
/* 42 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 44 */     List<ImportStatus> statusList = DataSourceManager.getImportStatus(account);
/* 45 */     Element response = zsc.createElement(MailConstants.GET_IMPORT_STATUS_RESPONSE);
/*    */     
/* 47 */     for (ImportStatus status : statusList) {
/* 48 */       DataSource ds = prov.get(account, Key.DataSourceBy.id, status.getDataSourceId());
/*    */       
/* 50 */       Element eDataSource = response.addElement(ds.getType().name());
/* 51 */       eDataSource.addAttribute("id", status.getDataSourceId());
/* 52 */       eDataSource.addAttribute("isRunning", status.isRunning());
/*    */       
/* 54 */       if ((status.hasRun()) && (!status.isRunning())) {
/* 55 */         eDataSource.addAttribute("success", status.getSuccess());
/* 56 */         if ((!status.getSuccess()) && (status.getError() != null)) {
/* 57 */           eDataSource.addAttribute("error", status.getError());
/*    */         }
/*    */       }
/*    */     }
/* 61 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetImportStatus.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */